<?php 
if (isset($chapter) && $chapter)
{
?>
  <div class="bodywrap"> 
    <div data-role="page" id="<?php echo $key+1;?>" data-theme="e" class="searchPage" data-url="page=<?php echo $key+1;?>"> 
      <div data-role="content" style="margin:0;padding:0">
        <ul data-role="listview" data-inset="true" data-theme="e" style="margin:0;padding:0">
          <li id="listitem" style="margin:0;padding:0; border:0">
            <div class="subhead">Chapter: <?php echo $chapter->name; ?></div>
	          <div class="quizimg" align="center">
	          	<img src="<?php echo ApplicationConfig::getImageUrl("CHAPTER-IMAGES", array('file_name'=>$chapter->image));?>" height="30%" width="40%" style="margin:0"/>
            	<div>
	            	<?php 
	            		$pagecount = Page::getList("CHAPTER-ID",array("chapterid"=>$chapter['id'],'type'=>'page'));
    	  				$pdfcount =  Page::getList("CHAPTER-ID",array("chapterid"=>$chapter['id'],'type'=>'pdf'));
    	   				if(!empty($pdfcount))
    	   				{
    	  			?>
    	          	<div class="playquiz" style="margin:0 auto">
    	          		<a data-icon="arrow-r" rel="external" href="<?php echo ApplicationConfig::getURL('', 'site', 'viewPdf',array('chapter'=>$chapter['id']))?>"  data-role="button" class="ui-btn-right" data-theme="e" style="width:98%" ><?php echo "Tutorial";?></a>
    	          	</div>
                	<br clear="all"/> 
                  	<?php 
    	   				}
         				//if(!empty($pagecount))
         				//{
					?>
                			<div class="playquiz" style="margin:0 auto">
                				<a data-icon="arrow-r" rel="external" href="<?php echo ApplicationConfig::getURL('', 'site', 'viewVideo',array('chapter'=>$chapter['id']))?>" data-role="button" class="ui-btn-right" data-theme="e" style="width:98%"> 
                					<?php echo "Summary Movie";?>
                				</a>
                			</div>
                			<br clear="all"/>
                	<?php 
         				//}
         			?>
                	<?php 	
                		$quizdetails=Quiz::getList('CHAPTER-ID', array('chapterid'=>$chapter->id));
                    	if(!empty($quizdetails))
                    	{
                	?>
		            		<div class="playquiz" style="margin:0 auto"><a data-icon="arrow-r" rel="external" href="<?php echo ApplicationConfig::getURL('', 'site', 'viewQuiz',array('chapter'=>$chapter['id']))?>" data-role="button" class="ui-btn-right" data-theme="e" style="width:98%"><?php echo "Quiz";?></a></div>     
	             	<?php 
                    	}
                    ?>
            	</div>
<?php 
	}
	else
	{
		$this->pageTitle="Chapter Not Found";
	    echo "Error while loading Chapter. please try Later.";
	}
?>
		</li>
    </ul>
</div>
</div>
</div>    

<script type="text/javascript">
  function jumpto()
  {
    var jumpto=document.getElementById("jumpto").value;
    if(jumpto && jumpto!="")
    {
	     window.location.href="<?php echo ApplicationConfig::getURL('', 'site', 'viewPages',array('chapter'=>$chapter->id)) ?>&page="+jumpto;
    }
    else
    {
	     alert("Please Enter Page Number");
    }
  }
</script>